package com.upic.serviceImpl;

import com.upic.po.jurisdiction.OperatorJurisdiction;
import com.upic.repository.OperatorJurisdictionRepository;
import com.upic.service.OperatorJurisdictionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by zhubuqing on 2018/2/7.
 */
@Service("operatorJurisdictionService")
public class OperatorJurisdictionServiceImpl implements OperatorJurisdictionService {
    @Autowired
    private OperatorJurisdictionRepository operatorJurisdictionRepository;

    @Override
    public OperatorJurisdiction saveOperatorJurisdiction(OperatorJurisdiction operatorJurisdiction) {
        return operatorJurisdictionRepository.save(operatorJurisdiction);
    }

    @Override
    public String deleteOperatorJurisdiction(long operatorJurisdictionId) {
        operatorJurisdictionRepository.delete(operatorJurisdictionId);
        return "SUCCESS";
    }

    @Override
    public Page<OperatorJurisdiction> searchOperatorJurisdiction(Pageable pageable) {
        return operatorJurisdictionRepository.findAll(pageable);
    }

    @Override
    public List<OperatorJurisdiction> searchOperatorJurisdiction() {
        return operatorJurisdictionRepository.findAll();
    }

    @Override
    public OperatorJurisdiction findOne(long operatorJurisdictionId) {
        return operatorJurisdictionRepository.findOne(operatorJurisdictionId);
    }

    @Override
    public OperatorJurisdiction upateOperatorJurisdiction(OperatorJurisdiction operatorJurisdiction) {
        return operatorJurisdictionRepository.saveAndFlush(operatorJurisdiction);
    }
}
